﻿using System;
using Iot.Shared.Path;

namespace Iot.RealTimeData.RealTimeData;

public interface IOnValueFactory
{
    private static readonly Type OnFloatValue = typeof(IOnFloatValue);
    private static readonly Type OnEnumValue = typeof(IOnEnumValue);
    private static readonly Type OnSwitchingValue = typeof(IOnSwitchingValue);
    private static readonly Type OnIntegerValue = typeof(IOnIntegerValue);


    T1 Create<T, T1>(DevicePath path) where T1 : IShowValue<T>, ISetValue<T>
    {
        return typeof(T1) switch
        {
            var a when a == OnFloatValue => (T1)CreateOnFloatValue(path),
            var b when b == OnEnumValue => (T1)CreateOnEnumValue(path),
            var c when c == OnSwitchingValue => (T1)CreateOnSwitchingValue(path),
            var d when d == OnIntegerValue => (T1)CreateOnIntegerValue(path),
            _ => throw new NotImplementedException()
        };
    }

    IOnFloatValue CreateOnFloatValue(DevicePath path);
    IOnIntegerValue CreateOnIntegerValue(DevicePath path);

    IOnEnumValue CreateOnEnumValue(DevicePath path);

    IOnSwitchingValue CreateOnSwitchingValue(DevicePath path);
}